      subroutine allocpdm
!
      use param
      use allocs
!
#include <global.h>
	include 'ntbytes.h'
      include 'geom.h'
      include 'geomf.h'
      include 'xsec.h'
      include 'sanm.h'
      include 'sanmjin.h'
      include 'nem.h'
      include 'setls.h'
      include 'eigv.h'
      include 'cmfd.h'
      include 'cmfdp1.h'
      include 'scmfdp1.h'

! geometry variables    
      call dmalloc(hz,tnode)
      call dmalloc(rhz,tnode)
      call dmalloc(comp,tnode)
!
      call dmalloc(compf,fnode)
      call dmalloc(hzf,fnode)
      call dmalloc(rhzf,fnode)

! xsec varaibles
      call dmalloc(xsd,2,tnode,ng)
      call dmalloc(xst,tnode,ng)
      call dmalloc(xsr,tnode,ng)
      call dmalloc(rxst,tnode,ng)
      call dmalloc(rxsr,tnode,ng)
      call dmalloc(xsnf,tnode,ng)
      call dmalloc(xchi,tnode,ng)
      call dmalloc0(betax,1,2,0,tnode+1,1,ng)
      call dmalloc0(beta,1,2,0,tnode+1,1,ng)
!
      call dmalloc(xsdf,2,fnode,ng)
      call dmalloc(xstf,fnode,ng)
      call dmalloc(xsrf,fnode,ng)
      call dmalloc(rxstf,fnode,ng)
      call dmalloc(rxsrf,fnode,ng)
      call dmalloc(xsff,fnode,ng)
      call dmalloc(xchif,fnode,ng)
      call dmalloc0(betaf,1,2,0,fnode+1,1,ng)

! 2node SANM
      call dmalloc(j1_err,ng)
      call dmalloc(j2_err,ng)
      call dmalloc(j1_old,ng)
      call dmalloc(j2_old,ng)
      call dmalloc(eigvec1,tnode,ng)
      call dmalloc(eigvec2,tnode,ng)
      call dmalloc(imq1,tnode,ng)
      call dmalloc(imq2,tnode,ng)
      call dmalloc0(cf,0,4,1,tnode,1,ng)
      call dmalloc0(fsc,0,4,1,tnode)
      call dmalloc0(scs,0,4,1,tnode)
      call dmalloc(ksq,2,tnode,ng)
      call dmalloc(krt,2,tnode,ng)
      call dmalloc(kqu,2,tnode,ng)
      call dmalloc(ksx,2,tnode,ng)
      call dmalloc(rkrt,2,tnode,ng)
      call dmalloc(rksq,2,tnode,ng)
      call dmalloc(rkqu,2,tnode,ng)
      call dmalloc(rksx,2,tnode,ng)
      call dmalloc(sigd,2,tnode,ng)
      call dmalloc(rsigd,2,tnode,ng)
      call dmalloc(cosa,2,tnode,ng)
      call dmalloc(sinb,2,tnode,ng)
      call dmalloc(jnet,2,tnode+1,ng)
      call dmalloc0(cp,0,4,1,2,1,tnode,1,ng)
!     temporary
      call dmalloc(tcp01,tnode,ng)
      call dmalloc(tcp11,tnode,ng)
      call dmalloc(tcp21,tnode,ng)
      call dmalloc(tcp31,tnode,ng)
      call dmalloc(tcp41,tnode,ng)
      call dmalloc(tcp02,tnode,ng)
      call dmalloc(tcp12,tnode,ng)
      call dmalloc(tcp22,tnode,ng)
      call dmalloc(tcp32,tnode,ng)
      call dmalloc(tcp42,tnode,ng)
      call dmalloc(tcosa1,tnode,ng)
      call dmalloc(tcosa2,tnode,ng)
      call dmalloc(tsinb1,tnode,ng)
      call dmalloc(tsinb2,tnode,ng)

! 1node NEM
      call dmalloc(nemsrc,fnode,ng)
      call dmalloc(jinl,2,fnode,ng)
      call dmalloc(jinr,2,fnode,ng)
      call dmalloc(joutl,2,fnode,ng)
      call dmalloc(joutr,2,fnode,ng)
      call dmalloc(fm,2,fnode,ng)
      call dmalloc(sm,2,fnode,ng)
      call dmalloc(sigdf,2,fnode,ng)
      call dmalloc(rsigdf,2,fnode,ng)
      call dmalloc(sflx,2,fnode+1,ng)
      call dmalloc(jnetf,2,fnode+1,ng)
      call dmalloc(sfl,2,fnode,ng)
      call dmalloc(sfr,2,fnode,ng)
      call dmalloc(ajil,2,tnode,ng)
      call dmalloc(ajir,2,tnode,ng)
      call dmalloc0(flp,0,4,1,ng)
      call dmalloc0(fscf,0,4,1,fnode)
      call dmalloc0(sscf,0,4,1,fnode)
      call dmalloc0(aflx,1,2,0,fnode+1,1,ng)
      call dmalloc0(pphi,1,2,0,fnode+1,1,ng)
      call dmalloc0(qsf,0,4,1,fnode,1,ng)

! CMFD linear system variables
      call dmalloc(dprob,tnode,ng)
      call dmalloc(dtilf,4,2,tnode,ng)
      call dmalloc(dhat,4,2,tnode,ng)
      call dmalloc(dhato,4,2,tnode,ng)
      call dmalloc(diagf,4,tnode,ng)
      call dmalloc(cczf,4,2,tnode,ng)
      call dmalloc(bdl,4,tnode,ng)
      call dmalloc(bdd,4,tnode,ng)
      call dmalloc(bdu,4,tnode,ng)
      call dmalloc(fcf,2,tnode+1,ng)

! CMFD P1
      call dmalloc(y,tnode)
      call dmalloc(digf,tnode,ng)
      call dmalloc(delinvf,tnode,ng)
      call dmalloc(deliauf,tnode,ng)
      call dmalloc(dtill,tnode,ng)
      call dmalloc(dtilr,tnode,ng)
      call dmalloc(dhatl,tnode,ng)
      call dmalloc(dhatr,tnode,ng)
      call dmalloc(czf,2,tnode,ng)

! CMFD P1 Sequence
      call dmalloc(dtl,2,tnode,ng)
      call dmalloc(dtr,2,tnode,ng)
      call dmalloc(dhl,2,tnode,ng)
      call dmalloc(dhr,2,tnode,ng)
      call dmalloc(flcf,2,tnode+1,ng)

! SANM_Jin
      call dmalloc(sfrt,tnode+1,ng)
      call dmalloc(flcor,tnode+1,ng)
      call dmalloc(jin,2,tnode,ng)
      call dmalloc(sflux,2,tnode+1,ng)

! Eigenvalue problem variables
      call dmalloc(psif,tnode)
      call dmalloc(psifd,tnode)      
      call dmalloc(src,2,tnode,ng)
      call dmalloc0(avgflx,1,2,0,tnode+1,1,ng)
      call dmalloc0(psphi,1,2,0,tnode+1,1,ng)
      call dmalloc0(qs,0,4,1,tnode,1,ng)

!   
      return
      end
